package com.example.wanandroid.mapper;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

@Component
public interface ViewMapper {

    /**
     * 查所有人问题 不需要登录
     *
     * @return
     */
    @Select("SELECT * FROM v_question_user")
    List<HashMap<String, Object>> getAllQuestions();

    /**
     * 查某人的问题
     *
     * @return
     */
    @Select("SELECT * FROM v_question_user WHERE userid=#{userId}")
    List<HashMap<String, Object>> getQuestionsByUserId(long userId);

    /**
     * 根据问题id查询问题详情
     *
     * @param questionId
     * @return
     */
    @Select("SELECT * FROM v_question_user WHERE questionId=#{questionId}")
    HashMap<String, Object> getQuestionById(long questionId);

    /**
     * 查某人的回答
     *
     * @return
     */
    @Select("SELECT * FROM v_answer_user_question WHERE answerUserId =#{userId}")
    List<HashMap<String, Object>> getAnswersByUserId(long userId);

    /**
     * 查某个问题的回答
     *
     * @return
     */
    @Select("SELECT * FROM v_answer_user_question WHERE questionId =#{questionId}")
    List<HashMap<String, Object>> getAnswersByQuestionId(long questionId);


}
